package com.probiz.estore.imports.handler.customer;

import com.probiz.estore.common.model.customer.Customer;
import com.probiz.estore.customer.service.CustomerManager;
import com.probiz.estore.imports.handler.PersistenceHandler;
import com.probiz.estore.imports.model.ImportModel;

public class CustomerPersistenceHandlerImpl implements PersistenceHandler {
    private CustomerManager customerManager;

	public void setCustomerManager(CustomerManager customerManager) {
		this.customerManager = customerManager;
	}

	public void saveOrUpdate(ImportModel importModel) {
		Customer customer = (Customer) importModel.getTarget();
		
		if(customer.getAppuserId() == null){
			customer.setCreateBy(importModel.getAppUserId());
		}
		customer.setUpdateBy(importModel.getAppUserId());
		
        customerManager.saveFullyForImport(customer);
		importModel.setResult(ImportModel.RESULT_SUCCESS);
        
	}

	public void validate(ImportModel importModel) {
		
	}

}
